<div class="bjui-row col-2">
    <label class="row-label">角色名称</label>
    <div class="row-input required">
        <input type="text" name="name" id="roles-name" data-rule="required">
    </div>
    <label class="row-label">备注</label>
    <div class="row-input">
        <input type="text" name="memo" id="roles-memo">
    </div>
    <input type="hidden" id="roles-getid" value="${id}">
    <input type="hidden" id="roles-id">
    <input type="hidden" id="roles-createdate">
</div>
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn-close" data-icon="close">取消</button>
        </li>
        <li>
            <button onclick="return commit()" class="btn-default" id="addrole" data-icon="save">保存</button>
        </li>
    </ul>
</div>
<script>
    $(function () {
        var id=$("#roles-getid").val();
        if (id!=null&&id!=""){
            $.ajax({
                type:"POST",
                url:"/sysmanage/roles/getRole.do",
                data:{'id':id},
                cache:true,
                dataType:'JSON',
                success:function(data){
                    bindModule(data);
                }
            })
        }
        $("#addrole").click(function () {
            BJUI.navtab('refresh', 'sysrole');
        })
    });
    function commit() {
        var id = $("#roles-id").val();
        var name = $("#roles-name").val();
        var createdate = $("#roles-createdate").val();
        var memo = $("#roles-memo").val();
        var module = new Object();
        module.id = id;
        module.name = name;
        module.createdate = createdate;
        module.memo = memo;

        console.log(module);
        console.log(JSON.stringify(module));
        $.ajax({
            type: "POST",
            url: "/sysmanage/roles/edit.do?",
            //{"id":"1","name":"管理员","createdate":"1503642104000","memo":"管理员"}
            data: JSON.stringify(module),
            dataType: 'json',
            cache: true,
            contentType: "application/json;charset=UTF-8",
            success: function (data) {
                if (data.Message === "ok") {
                    BJUI.alertmsg('ok', data.content)
                }
            }
        })
    }


    function bindModule(data) {
        $("#roles-id").val(data.id);
        $("#roles-name").val(data.name);
        $("#roles-createdate").val(data.createdate);
        $("#roles-memo").val(data.memo);
    }

</script>